package com.zb.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zb.entity.ZjBrandDescribe;
import com.zb.mapper.ZjBrandDescribeMapper;
import com.zb.service.ZjBrandDescribeService;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 品牌介绍表 服务实现类
 * </p>
 *
 * @author WEN
 * @since 2023-08-03
 */
@Service
public class ZjBrandDescribeServiceImpl extends ServiceImpl<ZjBrandDescribeMapper, ZjBrandDescribe> implements ZjBrandDescribeService {

    // 新增品牌介绍
    @Override
    public void save(Long custAccId, Long id, String describe) {
        ZjBrandDescribe brandDescribe = new ZjBrandDescribe();
        brandDescribe.setId(id);
        brandDescribe.setCustAccId(custAccId);
        brandDescribe.setInfo(describe);
        this.save(brandDescribe);
    }

    // 修改品牌介绍
    @Override
    public void updateById(Long id, String describe) {
        ZjBrandDescribe brandDescribe = new ZjBrandDescribe();
        brandDescribe.setId(id);
        brandDescribe.setInfo(describe);
        this.updateById(brandDescribe);
    }

    // 根据ID获取品牌介绍
    @Override
    public String getInfoById(Long id) {
        QueryWrapper<ZjBrandDescribe> wrapper = new QueryWrapper<>();
        wrapper.select("info");
        wrapper.eq("id", id);
        ZjBrandDescribe describe = this.getOne(wrapper);
        return null != describe? describe.getInfo() : "";
    }
}
